#include <iostream>
#include <utility>
#include <vector>
using namespace std;
#define int long long
const int N = 100010;
vector<int> p;
vector<int> a(N);
vector<int> b(N);
vector<int> c(N);
vector<int> cha(N);
vector<int> he(N);
signed main() {
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int temp;
        cin >> temp;
        p.push_back(temp);
    }
    for(int i = 0; i < m - 1; i++) {
        int x = p[i];
        int y = p[i + 1];
        if(x > y) {
            swap(x, y);
        }
        cha[x]++;
        cha[y]--;
    }
    for(int i = 1; i <= n - 1; i++) {
        he[i] = he[i - 1] + cha[i];
    }
    for(int i = 1; i <= n - 1; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        a[i] = x;
        b[i] = y;
        c[i] = z;
    }
    int ans = 0;
    for(int i = 1; i <= n - 1; i++) {
        if(he[i] * a[i] < (he[i] * b[i] + c[i])) {
            ans += he[i] * a[i];
        }else {
            ans += he[i] * b[i] + c[i];
        }
    }
    cout << ans << endl;
    return 0;
}